<?php if (!defined('THINK_PATH')) exit();?><!doctype html>
<html>
<head>
<meta charset="UTF-8"/>
<title>运营平台</title>
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
<meta name="renderer" content="webkit">
<!--<meta http-equiv="X-UA-Compatible" content="IE=edge">-->
<link type="text/css" rel="stylesheet" href="<?php echo get_style_cdnurl();?>paimai/yunying/css/common.css?v=20170207" />
<link type="text/css" rel="stylesheet" href="<?php echo get_style_cdnurl();?>paimai/yunying/css/table.css?v=20170117" />
<link type="text/css" rel="stylesheet" href="<?php echo get_style_cdnurl();?>paimai/yunying/css/jquery-ui.css" />
<script src="<?php echo get_style_cdnurl();?>paimai/yunying/js/jquery-1.11.1.js" type="text/javascript"></script>
<script src="<?php echo get_style_cdnurl();?>paimai/yunying/js/jquery-ui.min.js" type="text/javascript"></script>
 <script src="<?php echo get_style_cdnurl();?>paimai/yunying/js/yunIndex.js" type="text/javascript"></script>
<script src="<?php echo get_style_cdnurl();?>paimai/yunying/js/jquery-ym-datePlugin-0.1.js" type="text/javascript"></script>
<script src="<?php echo get_style_cdnurl();?>paimai/yunying/js/global.js" type="text/javascript"></script>
<script src="<?php echo get_style_cdnurl();?>paimai/cheshan/js/common.js" type="text/javascript"></script>
<script type="text/javascript" src="<?php echo get_style_cdnurl();?>paimai/yunying/js/jquery.placeholder.min.js"></script>
<script type="text/javascript">
 $(function(){
     $("input").placeholder();
     if (navigator.userAgent.indexOf("Safari") > -1) {
       $("input").css("lineHeight","normal !important");
     };
});
</script>

<style type="text/css">
    .store_status{border: 1px solid #d2d2d2;color: #303030;display: block;float: left;height: 26px;line-height: 26px;text-align: center;width: 300px;}
    .storeService{resize:none;border:solid 1px #d2d2d2;width:300px;height: 50px;}
    .storeType{width:300px;border:solid 1px #d2d2d2;height: 28px; line-height: 28px; text-indent: 10px;font-family:"微软雅黑";background:#fff url(http://img1.isou365.cn/paimai/yunying/images/sanjiao.jpg) no-repeat 280px 6px;}
    .coordinate{width:200px;height: 30px; line-height: 30px;color:#fff; background:#20ab4f;border:none;border-radius: 5px;}
    #file_qrcode{width:310px; overflow: hidden;font-size: 300px;height: 30px; opacity:0;cursor: pointer; position: absolute;top:0;left:100px; z-index: 2;}
    .employee ul li .storeMap{width:300px;height: 28px; line-height: 28px;color:#fff; background: #20ab4f;border: none; position: absolute;top:0;left:110px ;z-index:1;cursor: pointer;}
    .employee ul li .mapBtn{width:90px; display: inline-block; background: #20ab4f;color:#fff; text-align: center;}
    .employee ul li .mapCode{resize:none;border:solid 1px #d2d2d2;width:290px;height: 100px;padding:5px;}
    #file_qrcode-queue{margin-top: 40px;text-align: center;}

</style>
<script src="<?php echo get_style_cdnurl();?>paimai/yunying/plugin/ztree/jquery.ztree.core-3.5.js" type="text/javascript"></script>
<script src="<?php echo get_style_cdnurl();?>paimai/yunying/plugin/ztree/jquery.ztree.exedit-3.5.js" type="text/javascript"></script>
<script src="<?php echo get_style_cdnurl();?>paimai/yunying/js/city.js" type="text/javascript"></script>
<script type="text/javascript">
    var setting = {
        data: {
            simpleData: {
                enable: true
            }
        },
        callback:{
            onClick: zTreeOnClick
        }
    };
    var zNodes =[
    <?php foreach($list as $item):?>
    {id:<?php echo $item['id'];?>, pId:<?php echo $item['pid'];?>, name:"<?php echo $item['name'];?>",<?php echo $item['id']==1 ? "open: true" : '' ;?>},
    <?php endforeach;?>
    ];
    function zTreeOnClick( event, treeId, treeNode){
        var depart_id = treeNode.id;
        $("#depart_id").val(treeNode.id);
        $("#depart").val(treeNode.name);
        $(".zTreeDemoBackground").fadeOut();
        $(".arer-sheng").fadeOut();
        $(".arer-shi").fadeOut();
        $(".arer-qu").fadeOut();
    }
    $(document).ready(function(){
        $.fn.zTree.init($("#tree"), setting, zNodes);

        $("#depart").click(function(){
            $(".employee .zTreeDemoBackground").fadeToggle();
            $("#tree").show();
        })

        $("#depart").click(function(event){
            $(this).siblings("ul").fadeIn()
            $(this).parent().siblings("li").find("ul").fadeOut();
            $(".arer-sheng ul,.arer-shi ul,.arer-qu ul").fadeIn();
            $(".arer-sheng").fadeOut();
            $(".arer-shi").fadeOut();
            $(".arer-qu").fadeOut();
            event.stopPropagation();
        });

        $("body").click(function(event){
            $(".employee .menbox").fadeOut();
            $(".employee .zTreeDemoBackground").fadeOut();
            event.stopPropagation();
        })
        $(".zTreeDemoBackground").click(function(event){
            event.stopPropagation();
        })
    });
</script>
</head>
<body>
<body>
<div class="header">
<div class="headerCo">
<span>你好,<?php echo ($user_info["real_name"]); ?><a href="<?php echo (WEB_URL); ?>Emp/logout">退出</a></span>
<h1><img src="<?php echo get_style_cdnurl();?>paimai/yunying/images/yun_logo.jpg"></h1>
</div>
</div>
<div class="mian">
    <div class="mianL">
    <dl>
        <dd>
            <a id="menu_sy" href="/Index/index" class="shouye">首页</a>
        </dd>
        <?php foreach ($tree_menu as $key => $value): ?>
          <dd>
            <span id="menu_<?php echo ($value['first_char']); ?>" ><img src="<?php echo get_style_cdnurl();?>paimai/yunying/images/yun_jia.jpg"><?php echo ($value['name']); ?></span>
            <ul style="display: none;">
                <?php if (!empty($value['children'])): ?>
                    <?php foreach ($value['children'] as $k => $v): ?>
                        <li><a id='menu_<?php echo ($v["first_char"]); ?>' href="<?php echo ($v['url']); ?>"><?php echo ($v['name']); ?></a></li>
                    <?php endforeach ?>
                <?php endif ?>
            </ul>
        <?php endforeach ?>
    </dl>
</div>

<?php $menu = 'nrgl.mdgl'; ?>
<?php $menu=json_encode(explode('.', $menu)); ?>
<script>
    $(function () {
        var cur_menu = '<?php echo ($menu); ?>', cur_menu = eval('[' + cur_menu + ']'), cur_menu = cur_menu[0];
        if (cur_menu == "sy") {
            $("#menu_sy").removeClass('shouye').addClass('current');
        }
        $('#menu_' + cur_menu[0]).click();
        $('#menu_' + cur_menu[0]).find("img").attr("src", "http://img1.isou365.cn/paimai/yunying/images/yun_jie.jpg");
        $(".mianL").css("height", $(document).height() - 95);
        $('#menu_' + cur_menu[1]).addClass('current');
    });
</script>

    <form id="store_form" action="/StoreManage/add" method="post"  >
        <div class="mianR">
            <h3 class="cha"><?php if($store['store_id'] > 0): ?>编辑<?php else: ?>新增<?php endif; ?>门店</h3>
            <div class="shangFrom shangFrom1 clearfix"></div>
            <div><input type="button" value="查询坐标（百度地图）" class="coordinate" onclick="window.open('http://api.map.baidu.com/lbsapi/getpoint/');"/></div>
            <div class="employee">
                <ul class="clearfix">
                    <li>
                        <span>*门店名称</span>
                        <input type="text"  name="store_name" value="<?php echo ($store["store_name"]); ?>"  placeholder="门店名称"/>
                    </li>
                    <li>
                        <span>*门店负责人</span>
                        <input type="text"  name="store_lead" value="<?php echo ($store["store_lead"]); ?>"  placeholder="门店负责人"/>
                    </li>
                    <li>
                        <span>*所在地区</span>												
                        <script>
                            var add = new AddressCom();
                        </script>
                    </li> 
                     <li>
                        <span>*负责人手机号</span>
                        <input type="text"  name="lead_mobile" value="<?php echo ($store["lead_mobile"]); ?>"  placeholder="负责人手机号"/>
                    </li>
                      <li>
                        <span>*详细地址</span>
                        <input type="text"  name="store_address" value="<?php echo ($store["address"]); ?>" placeholder="门店详细地址" />
                    </li>
                     <li>
                        <span>*负责人邮箱</span>
                        <input type="text"  name="lead_email" value="<?php echo ($store["lead_email"]); ?>"  placeholder="负责人邮箱"/>
                    </li>
                    <li>
                        <span>*门店电话</span>
                        <input type="text"  name="store_tel" value="<?php echo ($store["store_tel"]); ?>"  placeholder="门店电话"/>
                    </li>
<!--                    <li>
                        <span>状态</span>
                        <select name="store_status" class="store_status">
                            <?php if($store["status"] == 0): ?><option value="0" selected>正常</option>
                            <option value="1">禁用</option>
                            <?php else: ?>
                                <option value="0">正常</option>
                                <option value="1" selected>禁用</option><?php endif; ?>
                        </select>
                    </li>-->

                    <li>
                        <span>*门店类型</span>
                        <select name="type" class="storeType">
                            <option value="1" <?php if($store['type'] == 1): ?>selected="selected"<?php endif; ?>>体验店</option>
                            <option value="2" <?php if($store['type'] == 2): ?>selected="selected"<?php endif; ?>>社区门店</option>
                            <option value="3" <?php if($store['type'] == 3): ?>selected="selected"<?php endif; ?>>交付店</option>
                        </select>
                    </li>

                    <li>
                        <span>服务范围</span>
                        <textarea cols="40" rows="3" name="service" class="storeService"><?php echo ($store["service"]); ?></textarea>
                    </li>
                    <li>
                        <span>关联部门</span>
                        <input type="text" id="depart"  value="<?php echo ($store["depart_name"]); ?>"  placeholder="请选择关联部门" readonly>
                        <input type='hidden' id='depart_id' name="depart_id" value="<?php echo ($store["depart_id"]); ?>" />
                        <div class="zTreeDemoBackground left">
                            <ul id="tree" class="ztree"></ul>
                        </div>

                    </li>


                    <li>
                        <span>*坐标(X)</span>
                        <input type="text" name="pointer_x" value="<?php echo ($store["pointer_x"]); ?>">
                    </li>
                    <li>
                        <span><a class="mapBtn" href="http://api.map.baidu.com/lbsapi/creatmap/index.html" target="_blank" title="获取百度地图代码">百度地图代码</a></span>
                        <textarea name="script" class="mapCode"><?php echo ($store["script"]); ?></textarea>
                    </li>
                    <li>
                        <span>*坐标(Y)</span>
                        <input type="text"  name="pointer_y" value="<?php echo ($store["pointer_y"]); ?>"/>
                    </li>

                    <li>
                        <span>地图二维码</span>
                        <input type="button" value="请选择文件" class="storeMap" readonly>
                        <input type="file" class="file_upload_style" id="file_qrcode" onclick="uploadPic('qrcode')">
                        <input type="hidden" name="qrcode" id="qrcode" value="<?php echo ($store["qrcode"]); ?>"/>
                        <div class="upload-img-box" style="margin-top: 40px; text-align: center;">
                            <div class="upload-pre-item">
                                <?php if($store["qrcode"] != ''): ?><img style="max-width: 400px;max-height: 400px;" src="<?php echo ($store["qrcode"]); ?>" /><?php endif; ?>
                            </div>
                        </div>
                    </li>

                </ul>
            </div>
            <div class="yongBtn">
                <input type="hidden"  name="channel_id" value="<?php echo ($store["channel_id"]); ?>" />
                <input type="hidden"  name="store_id" value="<?php echo ($store["store_id"]); ?>" />
                <input type="button" value="确定" class="queding" />
                <input name="重置" type="reset" class="quxiao" onclick="history.go(-1);" value="取消" />
            </div>
        </div>
    </form>
</div>
<div class="clear"></div>
<script type="text/javascript" src="/Public/static/uploadify/jquery.uploadify.min.js"></script>
<script type="text/javascript">
    window.onload=function(){
        $(".employee ul .zTreeDemoBackground ul li span").click(function(){

    var store_id = '<?php echo ($store["store_id"]); ?>';
            if($('.arer-sheng ul').css("display")=="block"){
                $(".arer-sheng ul,.arer-shi ul,.arer-qu ul").fadeOut();
            }else{
                $(".arer-sheng ul,.arer-shi ul,.arer-qu ul").fadeIn();
            }
       

        })
    }
    var store_id = '<?php echo ($store["store_id"]); ?>';
    if(store_id>0){
        add.set_init(["<?php echo ($store["province"]); ?>", "<?php echo ($store["city"]); ?>", "<?php echo ($store["area"]); ?>"]);//初始值
    }
    $(".queding").click(function(){
            var btn_obj = $(this);
            var post_data = $("#store_form").serialize();
            btn_obj.val("提交中...").attr("disabled", 'disabled');
            $.post("<?php echo U('/StoreManage/add');?>", post_data, function (data) {
                if (data.code != 200) {
                    shibai_alert(data.msg, 1500);
                    btn_obj.val("确定").removeAttr("disabled style");
                    return false;
                }
                btn_alert((store_id>0?'更新':'添加')+'成功', 1500, function () {
                    location.href = "<?php echo U('StoreManage/index');?>";
                });
            }, "json");
    })
</script>
<script type="text/javascript">
//        $(".file_upload_style").trigger("click");
        uploadPic('qrcode');
        function uploadPic(id) {
            /* 初始化上传插件 */
            $("#file_" + id).uploadify({
                "height": 30,
                "swf": "/Public/static/uploadify/uploadify.swf",
                "fileObjName": id,
                "buttonText": "上传图片",
                "uploader": "/StoreManage/upload_pic",
                "width": 300,
                'removeTimeout': 1,
                'fileTypeExts': '*.jpg; *.png; *.gif;',
                "onUploadSuccess": uploadCallBack,
//                'onFallback': function() {
//                    alert('未检测到兼容版本的Flash.');
//                }
            });
        }
        function uploadCallBack(file, data) {
            var data = eval("("+data+")");
            if(data.code==200){
                 var src = data.data;
                $('#qrcode').val(src);
                $('.upload-img-box').html('<div class="upload-pre-item"><img style="max-width: 400px;max-height: 400px;" src="' + src + '"/></div>');
            }else{
                alert(data.msg)
            }
        }
        </script>
<div class="yunBei"></div>
<div class="loading"></div>
</body>
</html>